package com.pb.wkflow.core.camunda.bpmn.instanceImpl;

import com.pb.wkflow.core.camunda.bpmn.instance.ExternalInterface;
import com.pb.wkflow.core.camunda.bpmn.instance.Participants;
import com.pb.wkflow.core.camunda.bpmn.instance.UserParticipant;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.model.bpmn.impl.instance.BpmnModelElementInstanceImpl;
import org.camunda.bpm.model.xml.ModelBuilder;
import org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext;
import org.camunda.bpm.model.xml.type.ModelElementTypeBuilder;

import static org.camunda.bpm.model.bpmn.impl.BpmnModelConstants.CAMUNDA_NS;

/**
 * @author 苗益辉
 * @date 2022/5/24 16:26
 */
@Slf4j
public class ExternalInterfaceImpl extends BpmnModelElementInstanceImpl implements ExternalInterface {

    public ExternalInterfaceImpl(ModelTypeInstanceContext instanceContext) {
        super(instanceContext);
    }

    public static void registerType(ModelBuilder modelBuilder) {
        log.info("注册自定义远程接口 externalInterface");
        ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(ExternalInterface.class, "externalInterface")
                .namespaceUri(CAMUNDA_NS)
                .instanceProvider(new ModelElementTypeBuilder.ModelTypeInstanceProvider<ExternalInterface>() {
                    @Override
                    public ExternalInterface newInstance(ModelTypeInstanceContext instanceContext) {
                        return new ExternalInterfaceImpl(instanceContext);
                    }
                });
        typeBuilder.build();
    }
}
